package com.lxf.cn.quartz;

import com.lxf.cn.redis.RedisUitls;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * Created by liaoxuefeng on 2018/11/12.
 */

//@Component
public class Quartz {

    @Autowired
    RedisUitls redisUitls ;

    private final Logger logger = LoggerFactory.getLogger(this.getClass());


   // @Scheduled(cron = "0/1 * * * * ? ")
    public void task1() {
        // 如果redis 不存在。 執行任務調度， 設置redis 時間
        if (StringUtils.isNotBlank(redisUitls.getString("test"))) {
            logger.info("執行任務邏輯！！！");
        } else {
            logger.info("緩存在不執行！AAAAAAAAA");
            redisUitls.setValueAndLifeCycle("test", 180, "x");

        }
    }

    //@Scheduled(cron = "0/1 * * * * ? ")
    public void task2() {
        logger.info("tast2++++++++++++++++++++");
    }


}
